home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Shell ƒ / about.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.4 KB  |  101 lines  |  [TEXT/MMCC]

  1. #include "about.h"
  2. #include "prefs.h"
  3. #include "util.h"
  4. #include "text twiddling.h"
  5. #include "window layer.h"
  6. #include "graphics.h"
  7.  
  8. #define    kAboutTextID    128
  9.  
  10. static    Boolean            gSetupDone=FALSE;
  11. static    Handle            gTheTextHandle=0L;
  12.  
  13. void SetupTheAboutWindow(WindowPtr theWindow)
  14. {
  15.     unsigned char    *titleStr="\pAbout";
  16.     unsigned char    returnChar='\r';
  17.     long            oldSize;
  18.     
  19.     SetWindowWidth(theWindow, 170);
  20.     SetWindowHeight(theWindow, 212);
  21.     SetWindowType(theWindow, noGrowDocProc);
  22.     SetWindowTitle(theWindow, titleStr);
  23.     SetWindowHasCloseBox(theWindow, TRUE);
  24.     SetWindowMaxDepth(theWindow, 1);
  25.     SetWindowDepth(theWindow, 1);
  26.     SetWindowIsFloat(theWindow, FALSE);
  27.     SetWindowAutoCenter(theWindow, TRUE);
  28.     if (gSetupDone)
  29.         return;
  30.     
  31.     gTheTextHandle=Get1Resource('TEXT', kAboutTextID);
  32.     if (gTheTextHandle!=0L)
  33.         DetachResource(gTheTextHandle);
  34.     oldSize=GetHandleSize(gTheTextHandle);
  35.     HLock(gTheTextHandle);
  36.     SetHandleSize(gTheTextHandle, oldSize+gMyName[0]+gMyOrg[0]+1);
  37.     Mymemcpy((Ptr)((long)*gTheTextHandle+oldSize), (Ptr)&gMyName[1], gMyName[0]);
  38.     Mymemcpy((Ptr)((long)*gTheTextHandle+oldSize+gMyName[0]), &returnChar, 1);
  39.     Mymemcpy((Ptr)((long)*gTheTextHandle+oldSize+gMyName[0]+1), &gMyOrg[1], gMyOrg[0]);
  40.     HUnlock(gTheTextHandle);
  41.     gSetupDone=TRUE;
  42. }
  43.  
  44. void OpenTheAboutWindow(WindowPtr theWindow)
  45. {
  46.     TEHandle        hTE;
  47.     FontInfo        theFontInfo;
  48.     Rect            destRect, viewRect;
  49.     
  50.     hTE=GetWindowTE(theWindow);
  51.     if (hTE==0L)
  52.     {
  53.         GetTERect(theWindow, &destRect, FALSE);
  54.         viewRect=destRect;
  55.         hTE=TENew(&destRect, &viewRect);
  56.         SetWindowTE(theWindow, hTE);
  57.         TextFont((**hTE).txFont=geneva);
  58.         TextSize((**hTE).txSize=9);
  59.         TextFace((**hTE).txFace=0);
  60.         GetFontInfo(&theFontInfo);
  61.         (**hTE).fontAscent=theFontInfo.ascent;
  62.         (**hTE).lineHeight=theFontInfo.ascent+theFontInfo.descent+theFontInfo.leading;
  63.         HLock(gTheTextHandle);
  64.         SetTheText(theWindow, *gTheTextHandle, GetHandleSize(gTheTextHandle));
  65.         HUnlock(gTheTextHandle);
  66.         TESetAlignment(teCenter, hTE);
  67.         TESetSelect(0, 0, hTE);
  68.         TEAutoView(TRUE, hTE);
  69.         TESelView(hTE);
  70.     }
  71. }
  72.  
  73. void DisposeTheAboutWindow(WindowPtr theWindow)
  74. {
  75.     TEHandle        hTE;
  76.     
  77.     hTE=GetWindowTE(theWindow);
  78.     if (hTE!=0L)
  79.     {
  80.         TEDispose(hTE);
  81.         SetWindowTE(theWindow, 0L);
  82.     }
  83. }
  84.  
  85. void ShutDownTheAboutWindow(void)
  86. {
  87.     if (gTheTextHandle!=0L)
  88.         DisposeHandle(gTheTextHandle);
  89.     gTheTextHandle=0L;
  90. }
  91.  
  92. void KeyDownInAboutWindow(WindowPtr theWindow, unsigned char theChar)
  93. {
  94.     CloseTheWindow(theWindow);
  95. }
  96.  
  97. void MouseDownInAboutWindow(WindowPtr theWindow, Point thePoint)
  98. {
  99.     CloseTheWindow(theWindow);
  100. }
  101.